package com.cy.pj.sys.web.controller;

import com.cy.pj.common.util.PageUtil;
import com.cy.pj.sys.dao.SysLogDao;
import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.service.SysLogService;
import com.cy.pj.sys.web.pojo.JsonResult;
import com.github.pagehelper.ISelect;
import org.aspectj.lang.annotation.AfterThrowing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RequestMapping("/log/")
@RestController
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;
    @GetMapping("{id}")
    public JsonResult dofindById(@PathVariable Long id){
        return  new JsonResult(sysLogService.findById(id));
    }

    @GetMapping
    public  JsonResult doFindLogs( SysLog sysLog){
        return new JsonResult(PageUtil.startPage().doSelectPageInfo(()->sysLogService.findLogs(sysLog)));//lamuda表达式
//        return new JsonResult(PageUtil.startPage().doSelectPageInfo(
//                new ISelect(){
//                    @Override
//                    public void doSelect() {
//                        sysLogService.findLogs(sysLog);
//                    }
//                }
//        ));
    }
    @DeleteMapping("{ids}")
    public  JsonResult doDeleteById(@PathVariable Long... ids){
        return new JsonResult(sysLogService.deleteLogs(ids));
    }
}
